import { formatDate } from '@/utils/formatTime'
import { TableColumns } from '@pureadmin/table'
import { DICT_TYPE } from '@/utils/dict'
import DictTag from '@/components/DictTag/src/DictTag.vue'

interface TableColumnList extends Array<TableColumns> {}

export function useTable() {
  const columns: TableColumnList = [
    { prop: 'id', label: 'ID', width: 80, align: 'center' },
    {
      prop: 'nickname',
      label: '姓名',
      minWidth: 180,
      align: 'left',
      slot: 'nickname'
    },
    { prop: 'sex', label: '性别', minWidth: 80, align: 'center', slot: 'sex' },
    { prop: 'mobile', label: '手机', minWidth: 120, align: 'center' },
    { prop: 'userAge', label: '年龄', minWidth: 120, align: 'center' },
    { prop: 'userBirthday', label: '生日', minWidth: 130, align: 'center', slot: 'birthday' },
    { prop: 'jobNumber', label: '工号', minWidth: 100, align: 'center' },
    { prop: 'deptName', label: '部门', minWidth: 100, align: 'center' },
    { prop: 'postStrNames', label: '岗位', minWidth: 100, align: 'center' },
    { prop: '', label: '工龄', minWidth: 100, align: 'center' },
    // { prop: 'sourceTenantName', label: '归属商户', minWidth: 100, align: 'center' },
    {
      prop: 'userStatus',
      label: '员工状态',
      minWidth: 100,
      align: 'center',
      cellRenderer: ({ row }) => <DictTag type={DICT_TYPE.EMPLOYEE_STATUS} value={row.userStatus} />
    },
    {
      prop: 'status',
      label: '账号状态',
      minWidth: 100,
      align: 'center',
      cellRenderer: ({ row }) => <DictTag type={DICT_TYPE.COMMON_STATUS} value={row.status} />
    },
    {
      prop: 'createTime',
      label: '入职时间',
      minWidth: 180,
      align: 'center',
      formatter({ createTime }) {
        return formatDate(createTime)
      }
    },
    {
      prop: 'createTime',
      label: '创建时间',
      minWidth: 180,
      align: 'center',
      formatter({ createTime }) {
        return formatDate(createTime)
      }
    },

    {
      label: '操作',
      fixed: 'right',
      minWidth: 168,
      align: 'center',
      slot: 'operation'
    }
  ]

  return {
    columns
  }
}
